package com.masterclient.app.modules.goods.adapter;

import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.masterclient.app.App;
import com.masterclient.app.R;
import com.eoner.baselibrary.bean.goods.ShopBean;
import com.eoner.baselibrary.utils.ScreenUtils;

/**
 * 作者：sean
 * 创建时间：2017/8/10 10:22
 * 功能说明：
 */

public class ZhengAdapter extends BaseQuickAdapter<ShopBean.DataBean.ShProductRecomBean,BaseViewHolder>{

    public ZhengAdapter() {
        super(R.layout.item_zheng);
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopBean.DataBean.ShProductRecomBean item) {
//        App.picasso.load(item.getSh_image()).into((ImageView) helper.getView(R.id.iv_good));
        LinearLayout linearLayout = helper.getView(R.id.ll_main);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) linearLayout.getLayoutParams();
        params.width = ScreenUtils.getScreenWidth()-ScreenUtils.dp2px(50);
        if(helper.getLayoutPosition() == 0){
            params.leftMargin = ScreenUtils.dp2px(25);
            params.rightMargin = ScreenUtils.dp2px(8);
        }else if(helper.getLayoutPosition() == (mData.size()-1)){
            params.leftMargin = ScreenUtils.dp2px(0);
            params.rightMargin = ScreenUtils.dp2px(25);
        }else {
            params.leftMargin = ScreenUtils.dp2px(0);
            params.rightMargin = ScreenUtils.dp2px(8);
        }

        linearLayout.setLayoutParams(params);
        App.picasso.load(item.getSh_image())
                .resize(ScreenUtils.dp2px(320),ScreenUtils.dp2px(360))
                .placeholder(R.mipmap.defaults)
                .error(R.mipmap.defaults)
                .into((ImageView) helper.getView(R.id.iv_good));
    }
}
